#include <scene_graph_edit.h>
using namespace PhysLeo;

std::shared_ptr<SceneGraph> stvkBunny() {
	const float dt = 0.001f;
	std::cout << "StvK Bunny Demo" << std::endl;

	//construct fem cuda algorithm
	auto fem = std::make_shared<SymplecticEulerCuda<float>>();
    fem->fixed_freedom_ = std::make_shared<FixedFreedomCuda<float>>();
    fem->gravity_ = std::make_shared<GravityCuda<float>>();
    fem->internal_force_ = std::make_shared<FemCuda<float>>();
    fem->velocity_damping_ = std::make_shared<VelocityDampingCuda<float>>();


	//construct pdm cuda algorithm
	auto pdm = std::make_shared<SymplecticEulerCuda<float>>();
    pdm->fixed_freedom_ = std::make_shared<FixedFreedomCuda<float>>();
    pdm->gravity_ = std::make_shared<GravityCuda<float>>();
    pdm->internal_force_ = std::make_shared<PdmCuda<float>>();
    pdm->velocity_damping_ = std::make_shared<VelocityDampingCuda<float>>();

    //construct pdm cpu algorithm
    auto pdm_cpu = std::make_shared<SymplecticEulerCpu<float>>();
    pdm_cpu->fixed_freedom_ = std::make_shared<FixedFreedomCpu<float>>();
    pdm_cpu->gravity_ = std::make_shared<GravityCpu<float>>();
    pdm_cpu->internal_force_ = std::make_shared<PdmCpu<float>>();
    pdm_cpu->velocity_damping_ = std::make_shared<VelocityDampingCpu<float>>();

	//create bunny smesh
	Smesh bunny;
    bunny.loadFromFile("../../Model/Bunny/bunny.smesh");

	//root node
    auto root = std::make_shared<Node>();

    auto pdmbody = std::make_shared<DynamicBody<float>>(pdm, "pdm");
    //auto pdmbody = std::make_shared<DynamicBody<float>>(pdm_cpu, "pdm");
	root->addChild(pdmbody);
	auto pdm_data = pdmbody->getSimData();
    pdm_data->readGeometry(bunny);
    pdm_data->readSimulationConfig("../../Model/Bunny/bunny.ini");
	pdmbody->addRender(std::make_shared<PointRenderCuda<float>>());
    //pdmbody->addRender(std::make_shared<PointRenderCpu<float>>());
	pdmbody->setMaxDt(dt);

    return std::make_shared<SceneGraph>(root);
}